// var o;
// exports.PropConfig = exports.PropId = exports.PropType = void 0;
// var s;
// var c;
// var l;
// var AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
// var AL_GAME_HUA_ConfigHandler = require("./AL_GAME_HUA_ConfigHandler");
// var AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
// var AL_GAME_HUA_GoodsConfig = require("./AL_GAME_HUA_GoodsConfig");
// (l = exports.PropType || (exports.PropType = {}))[(l.GAME = 0)] = "GAME";
// l[(l.ENTER = 1)] = "ENTER";
// (c = s = exports.PropId || (exports.PropId = {}))[(c.TIPS_ENTER = 0)] = "TIPS_ENTER";
// c[(c.TIME_ENTER = 1)] = "TIME_ENTER";
// c[(c.STAR_ENTER = 2)] = "STAR_ENTER";
// c[(c.TIPS_GAME = 3)] = "TIPS_GAME";
// c[(c.REFRESH_GAME = 4)] = "REFRESH_GAME";
// c[(c.CHANGE_GAME = 5)] = "CHANGE_GAME";
// c[(c.TIME_GAME = 6)] = "TIME_GAME";
// var h = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.configs = [];
//         return t;
//     }
//     __extends(t, e);
//     t.getInstance = function () {
//         return this.instance || (this.instance = new t());
//     };
//     t.prototype.destroy = function () {
//         t.instance = null;
//     };
//     t.prototype.jiazai_peizhi = function () {
//         return __awaiter(this, void 0, Promise, function () {
//             var e;
//             var t;
//             var n;
//             var o;
//             var i;
//             var r;
//             return __generator(this, function (a) {
//                 switch (a.label) {
//                     case 0:
//                         return [4, this.yibu_jiazai_txt_peizhi("Prop")];
//                     case 1:
//                         if ((e = a.sent())) {
//                             t = e;
//                             for (n = 0; n < t.length; n++) {
//                                 o = t[n];
//                                 i = o.goodsId;
//                                 (r = AL_GAME_HUA_GoodsConfig.GoodsConfig.getInstance().huoqu_shangpin_miaoshu(i)) &&
//                                     ((o.name = r.name), (o.desc = r.desc));
//                             }
//                             t[s.TIPS_ENTER].unlock = AL_GAME_HUA_GameConst.GameConst.getInstance().prop_pop_level[0];
//                             t[s.TIME_ENTER].unlock = AL_GAME_HUA_GameConst.GameConst.getInstance().prop_pop_level[1];
//                             t[s.STAR_ENTER].unlock = AL_GAME_HUA_GameConst.GameConst.getInstance().prop_pop_level[2];
//                             t[s.TIPS_GAME].unlock = AL_GAME_HUA_GameConst.GameConst.getInstance().prop_game_level[0];
//                             t[s.REFRESH_GAME].unlock = AL_GAME_HUA_GameConst.GameConst.getInstance().prop_game_level[1];
//                             t[s.CHANGE_GAME].unlock = AL_GAME_HUA_GameConst.GameConst.getInstance().prop_game_level[2];
//                             t[s.TIME_GAME].unlock = AL_GAME_HUA_GameConst.GameConst.getInstance().prop_game_level[3];
//                             t[s.TIPS_ENTER].price = AL_GAME_HUA_GameConst.GameConst.getInstance().prop0_price;
//                             t[s.TIME_ENTER].price = AL_GAME_HUA_GameConst.GameConst.getInstance().prop1_price;
//                             t[s.STAR_ENTER].price = AL_GAME_HUA_GameConst.GameConst.getInstance().prop2_price;
//                             t[s.TIPS_GAME].price = AL_GAME_HUA_GameConst.GameConst.getInstance().prop3_price;
//                             t[s.REFRESH_GAME].price = AL_GAME_HUA_GameConst.GameConst.getInstance().prop4_price;
//                             t[s.CHANGE_GAME].price = AL_GAME_HUA_GameConst.GameConst.getInstance().prop5_price;
//                             t[s.TIME_GAME].price = AL_GAME_HUA_GameConst.GameConst.getInstance().prop6_price;
//                             this.configs = t;
//                             return [2, t];
//                         }
//                         return [2, null];
//                 }
//             });
//         });
//     };
//     t.prototype.huoqu_suoyou_de_peizhi = function () {
//         return this.configs;
//     };
//     t.prototype.huoqu_peizhi_genju_id = function (e) {
//         return this.configs[e];
//     };
//     t.prototype.huoqu_shuxing_shifou_yijiesuo = function (e, t) {
//         var n = this.configs[t];
//         return !!n && n.unlock <= e;
//     };
//     t.prototype.huoqu_shuxing_jinru_yindao = function (e) {
//         var t = this.configs[0];
//         var n = this.configs[1];
//         var o = this.configs[2];
//         return t.unlock != e || AL_GAME_HUA_GameData.GameData.getInstance().huoqu_prop_jiesuo(0)
//             ? n.unlock != e || AL_GAME_HUA_GameData.GameData.getInstance().huoqu_prop_jiesuo(1)
//                 ? o.unlock != e || AL_GAME_HUA_GameData.GameData.getInstance().huoqu_prop_jiesuo(2)
//                     ? -1
//                     : 2
//                 : 1
//             : 0;
//     };
//     t.prototype.huoqu_shuxing_jinru_xianshi = function () {
//         return AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() >= this.configs[0].unlock;
//     };
//     t.prototype.huoqu_suoyou_jinru_shuxing_yi_jiesuo = function () {
//         return AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() >= this.configs[2].unlock;
//     };
//     t.instance = null;
//     return t;
// })(AL_GAME_HUA_ConfigHandler.ConfigHandler);
// exports.PropConfig = h;

// 导入必要的模块
const AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
const AL_GAME_HUA_ConfigHandler = require("./AL_GAME_HUA_ConfigHandler");
const AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
const AL_GAME_HUA_GoodsConfig = require("./AL_GAME_HUA_GoodsConfig");

/** 
 * 表示游戏属性的类型枚举
 * @enum {number}
 */
const PropType = {
  GAME: 0,
  ENTER: 1
};
exports.PropType = PropType;

/** 
 * 表示游戏属性的ID枚举
 * @enum {number}
 */
const PropId = {
  TIPS_ENTER: 0,
  TIME_ENTER: 1,
  STAR_ENTER: 2,
  TIPS_GAME: 3,
  REFRESH_GAME: 4,
  CHANGE_GAME: 5,
  TIME_GAME: 6
};
exports.PropId = PropId;

/**
 * 配置属性类
 * 负责加载和管理游戏的属性配置。
 * @extends AL_GAME_HUA_ConfigHandler.ConfigHandler
 */
class PropConfig extends AL_GAME_HUA_ConfigHandler.ConfigHandler {
  constructor() {
    super();
    /** @type {Array} */
    this.configs = [];
  }

  /**
   * 获取实例，单例模式
   * @returns {PropConfig} - 返回PropConfig实例
   */
  static getInstance() {
    if (!PropConfig.instance) {
      PropConfig.instance = new PropConfig();
    }
    return PropConfig.instance;
  }

  /**
   * 销毁当前实例
   */
  destroy() {
    PropConfig.instance = null;
  }

  /**
   * 加载游戏属性配置
   * 异步加载文本配置文件，并根据配置文件设置属性配置
   * @returns {Promise<Array|null>}
   */
  async jiazai_peizhi() {
    try {
      const configData = await this.yibu_jiazai_txt_peizhi("Prop");

      if (configData) {
        configData.forEach(config => {
          const goodsId = config.goodsId;
          const goodsDesc = AL_GAME_HUA_GoodsConfig.GoodsConfig.getInstance().huoqu_shangpin_miaoshu(goodsId);
          if (goodsDesc) {
            config.name = goodsDesc.name;
            config.desc = goodsDesc.desc;
          }
        });

        const gameConstInstance = AL_GAME_HUA_GameConst.GameConst.getInstance();
        configData[PropId.TIPS_ENTER].unlock = gameConstInstance.prop_pop_level[0];
        configData[PropId.TIME_ENTER].unlock = gameConstInstance.prop_pop_level[1];
        configData[PropId.STAR_ENTER].unlock = gameConstInstance.prop_pop_level[2];
        configData[PropId.TIPS_GAME].unlock = gameConstInstance.prop_game_level[0];
        configData[PropId.REFRESH_GAME].unlock = gameConstInstance.prop_game_level[1];
        configData[PropId.CHANGE_GAME].unlock = gameConstInstance.prop_game_level[2];
        configData[PropId.TIME_GAME].unlock = gameConstInstance.prop_game_level[3];

        configData[PropId.TIPS_ENTER].price = gameConstInstance.prop0_price;
        configData[PropId.TIME_ENTER].price = gameConstInstance.prop1_price;
        configData[PropId.STAR_ENTER].price = gameConstInstance.prop2_price;
        configData[PropId.TIPS_GAME].price = gameConstInstance.prop3_price;
        configData[PropId.REFRESH_GAME].price = gameConstInstance.prop4_price;
        configData[PropId.CHANGE_GAME].price = gameConstInstance.prop5_price;
        configData[PropId.TIME_GAME].price = gameConstInstance.prop6_price;

        this.configs = configData;
        return configData;
      }
      return null;
    } catch (error) {
      console.error("Error loading config:", error);
      return null;
    }
  }

  /**
   * 获取所有的配置
   * @returns {Array} - 返回配置数组
   */
  huoqu_suoyou_de_peizhi() {
    return this.configs;
  }

  /**
   * 根据ID获取配置
   * @param {number} id - 需要获取的配置ID
   * @returns {Object} - 返回对应的配置对象
   */
  huoqu_peizhi_genju_id(id) {
    return this.configs[id];
  }

  /**
   * 检查属性是否已解锁
   * @param {number} level - 当前等级
   * @param {number} configId - 配置ID
   * @returns {boolean} - 返回是否已解锁
   */
  huoqu_shuxing_shifou_yijiesuo(level, configId) {
    const config = this.configs[configId];
    return !!config && config.unlock <= level;
  }

  /**
   * 获取进入指引属性
   * 根据传入的解锁等级，判断哪个属性是当前未解锁的
   * @param {number} level - 当前解锁等级
   * @returns {number} - 返回指引索引
   */
  huoqu_shuxing_jinru_yindao(level) {
    const configEnterTips = this.configs[PropId.TIPS_ENTER];
    const configEnterTime = this.configs[PropId.TIME_ENTER];
    const configEnterStar = this.configs[PropId.STAR_ENTER];
    
    if (configEnterTips.unlock !== level || !AL_GAME_HUA_GameData.GameData.getInstance().huoqu_prop_jiesuo(PropId.TIPS_ENTER)) {
      return configEnterTime.unlock !== level || !AL_GAME_HUA_GameData.GameData.getInstance().huoqu_prop_jiesuo(PropId.TIME_ENTER) ? 
             (configEnterStar.unlock !== level || !AL_GAME_HUA_GameData.GameData.getInstance().huoqu_prop_jiesuo(PropId.STAR_ENTER) ? -1 : PropId.STAR_ENTER) : 
             PropId.TIME_ENTER;
    }
    return PropId.TIPS_ENTER;
  }

  /**
   * 获取进入显示属性
   * 检查解锁等级是否超过显示等级的门槛
   * @returns {boolean} - 是否已解锁所有进入属性
   */
  huoqu_shuxing_jinru_xianshi() {
    return AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() >= this.configs[PropId.TIPS_ENTER].unlock;
  }

  /**
   * 检查是否所有进入属性均已解锁
   * @returns {boolean} - 是否已解锁所有进入属性
   */
  huoqu_suoyou_jinru_shuxing_yi_jiesuo() {
    return AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() >= this.configs[PropId.STAR_ENTER].unlock;
  }

  /** @type {PropConfig} */
  static instance = null;
}

exports.PropConfig = PropConfig;